﻿Public Class HollidayEdotor
    Private Sub ButtonX1_Click(sender As Object, e As EventArgs) Handles ButtonX1.Click

        If txth_id.Text.Trim = "" Then
            CMD.Parameters("@date") = DTh_date.Text
            Dim count = CMD.ExecuteScalar("Select count(*) from TBL_HOLIDAY where H_DATE=@date")
            If count > 0 Then
                MsgBox("This holiday already exist....!")
            Else
                CMD.Parameters("@date") = DTh_date.Text
                CMD.Parameters("@desc") = txth_desc.Text.ToString
                CMD.ExecuteNonQuery("INSERT INTO TBL_HOLIDAY VALUES(@date,@desc)")
                MsgBox("New Holiday has been record....!")
                Form1.loadholiday()
            End If
        Else
            CMD.Parameters("@id") = txth_id.Text
            CMD.Parameters("@date") = DTh_date.Text
            CMD.Parameters("@desc") = txth_desc.Text.ToString
            CMD.ExecuteNonQuery("UPDATE TBL_HOLIDAY SET H_DATE=@date,H_DES=@desc WHERE H_ID=@id")
            MsgBox("New Holiday has been Update....!")
            Form1.loadholiday()
        End If
        
        
    End Sub
End Class